package com.school.gift.controller;

import com.school.gift.domain.Evaluate;
import com.school.gift.domain.Order;
import com.school.gift.service.EvaluateService;
import com.school.gift.service.OrderService;
import com.school.support.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import zhibi.common.support.annocation.request.LoginInfo;

import java.util.Date;

/**
 * Created by 执笔 on 2017/3/6.
 */
@Controller
@RequestMapping("evaluate")
@LoginInfo(true)
public class EvaluateController extends BaseController {

    @Autowired
    private EvaluateService evaluateService;
    @Autowired
    private OrderService orderService;

    @RequestMapping("save")
    public String save(Evaluate evaluate){
        evaluate.setUserId(sessionUser().getId());
        evaluate.setAddtime(new Date());
        Order order = orderService.selectByPK(evaluate.getOrderId());
        order.setEvaluatetime(new Date());
        order.setStatus(5);
        orderService.updateByIdSelective(order);
        evaluateService.insertSelective(evaluate);
        return redirect("/order/myOrder");
    }

}
